var Users = function () {
	
	var options;

    var handle = function () {

    	var grid = new Datatable();
    	
        grid.init({
            src: $("#datatable_users"),
            fixedColumns: 2,
            onSuccess: function (data) {
            	
            },
            onError: function (data) {
               
            },
            dataTable: {
                "pageLength": 10,
                "ajax": {
                    "url": options.ctx + '/user/list'
                },
                "columnDefs": [{'orderable': false, 'targets': [0,1]}],
                "columns": [
                            {"render": function(data,type,full) {
								return '<div class="btn-group">'+
										'	<a href="#" class="btn blue-madison btn-xs btn-operation" data-toggle="dropdown">'+
										'		<i class="fa fa-cog"></i> ' + message['datatable.operation'] + 
										'	</a>'+
										'	<ul class="dropdown-menu pull-left">'+
										'		<li><a href="' + options.ctx + '/user/update/' + full.id + '" data-toggle="modal" data-target="#ajax-modal">修改</a></li>'+
										'		<li><a href="#">转移</a></li>'+
										'		<li><a href="#">删除</a></li>'+
										'		<li class="dropdown-submenu">'+
										'			<a href="#">状态变更</a>'+
										'			<ul class="dropdown-menu pull-left">'+
										'				<li><a href="#">' + (full.accountLocked ? '账户解锁' : '账户锁定') + '</a></li>'+
										'				<li><a href="#">' + (full.loginLocked ? '登录解锁' : '登录锁定') + '</a></li>'+
										'				<li><a href="#">' + (full.bankCardLocked ? '银行卡解锁' : '银行卡锁定') + '</a></li>'+
										'			</ul>'+
										'		</li>'+
										'		<li class="dropdown-submenu">'+
										'			<a href="#">额度变更</a>'+
										'			<ul class="dropdown-menu pull-left">'+
										'				<li><a href="#">额度调增</a></li>'+
										'				<li><a href="#">额度调减</a></li>'+
										'				<li><a href="#">发放分红</a></li>'+
										'			</ul>'+
										'		</li>'+
										'		<li class="dropdown-submenu">'+
										'			<a href="#">交易记录</a>'+
										'			<ul class="dropdown-menu pull-left">'+
										'				<li><a href="#">交易明细</a></li>'+
										'				<li><a href="#">投注记录</a></li>'+
										'				<li><a href="#">追号记录</a></li>'+
										'				<li><a href="#">返点记录</a></li>'+
										'				<li><a href="#">充值记录</a></li>'+
										'				<li><a href="#">提款记录</a></li>'+
										'				<li><a href="#">转账记录</a></li>'+
										'				<li><a href="#">转换记录</a></li>'+
										'				<li><a href="#">增减记录</a></li>'+
										'				<li><a href="#">分红记录</a></li>'+
										'				<li><a href="#">礼金记录</a></li>'+
										'			</ul>'+
										'		</li>'+
										'		<li><a href="#">角色分配</a></li>'+
										'	</ul>'+
										'</div>';
							}},
                            {"data": "id", "render": function(data,type,full) {
                            	return '<input type="checkbox" name="id[]" value="'+data+'">';
                            }},
                            
                            {"data": "userName"},
                            {"data": "nickName"},
                            {"data": "floor"},
                            {"data": "parentName"},
                            {"data": "layerId", "render": function(data,type,full){
								return $('select[name="search_EQ_layerId"] option[value="' + data + '"]').text();
							}},
                            {"data": "accountType", "render": function(data,type,full){
                            	return message['net.lanelife.casino.caipiao.entity.User.AccountType.'+data];
                            }},
                            {"data": "rebatePoint"},
                            
                        	{"data": "onlineStatus", "render": function(data,type,full) {
                            	return data == 'ONLINE' ? '<span class="label label-sm bg-green">' + message['net.lanelife.casino.caipiao.entity.User.OnlineStatus.ONLINE'] + '</span>' : '<span class="label label-sm bg-grey-silver">' + message['net.lanelife.casino.caipiao.entity.User.OnlineStatus.OFFLINE'] + '</span>';
                            }},
                        	{"data": "accountLocked", "render": function(data,type,full) {
                            	return data ? '<span class="label label-sm label-danger">' + message['net.lanelife.casino.caipiao.entity.User.AccountLocked.TRUE'] + '</span>' : '<span class="label label-sm label-success">' + message['net.lanelife.casino.caipiao.entity.User.AccountLocked.FALSE'] + '</span>';
                            }},
                        	{"data": "loginLocked", "render": function(data,type,full) {
                            	return data ? '<span class="label label-sm label-danger">' + message['net.lanelife.casino.caipiao.entity.User.LoginLocked.TRUE'] + '</span>' : '<span class="label label-sm bg-grey-silver">' + message['net.lanelife.casino.caipiao.entity.User.LoginLocked.FALSE'] + '</span>';
                            }},
                        	{"data": "bankCardLocked", "render": function(data,type,full) {
                            	return data ? '<span class="label label-sm label-success">' + message['net.lanelife.casino.caipiao.entity.User.BankCardLocked.TRUE'] + '</span>' : '<span class="label label-sm bg-grey-silver">' + message['net.lanelife.casino.caipiao.entity.User.BankCardLocked.FALSE'] + '</span>';
                            }},
                        	{"data": "layerLocked", "render": function(data,type,full) {
                            	return data ? '<span class="label label-sm label-danger">' + message['net.lanelife.casino.caipiao.entity.User.LayerLocked.TRUE'] + '</span>' : '<span class="label label-sm bg-grey-silver">' + message['net.lanelife.casino.caipiao.entity.User.LayerLocked.FALSE'] + '</span>';
                            }},
                        	
                        	{"data": "accountBalance", "class": "right"},
                        	{"data": "frozenBalance", "class": "right"},
                        	{"data": "agBalance", "class": "right"},
                        	{"data": "bbBalance", "class": "right"},
                        	
                        	{"data": "betTimes"},
                        	{"data": "betTotal", "class": "right"},
                        	{"data": "betMax", "class": "right"},
                        	{"data": "winTimes"},
                        	{"data": "winTotal", "class": "right"},
                        	{"data": "winMax", "class": "right"},
                        	{"data": "rechargeTimes"},
                        	{"data": "rechargeTotal", "class": "right"},
                        	{"data": "rechargeMax", "class": "right"},
                        	{"data": "withdrawTimes"},
                        	{"data": "withdrawTotal", "class": "right"},
                        	{"data": "withdrawMax", "class": "right"},
                        	{"data": "transferInTimes"},
                        	{"data": "transferInTotal", "class": "right"},
                        	{"data": "transferInMax", "class": "right"},
                        	{"data": "transferOutTimes"},
                        	{"data": "transferOutTotal", "class": "right"},
                        	{"data": "transferOutMax", "class": "right"},
                        	
                        	{"data": "createdDate"},
                        	{"data": "registerSource", "render": function(data,type,full){
                            	return message['net.lanelife.casino.caipiao.entity.User.RegisterSource.'+data];
                            }},
                        	
                        	{"data": "qq"},
                        	{"data": "email"},
                        	{"data": "mobile"},
                        	
                        	{"data": "lastLoginTime"},
                        	{"data": "lastLoginAddress"},
							
							{"data": "quota"},
                        	
                        	{"data": "lastModifiedBy"},
                        	{"data": "lastModifiedDate"}
                        ],
                "order": [
                    [4, "asc"]
                ]
            }
        });
        
    };

    return {
        init: function (opts) {
			
			options = $.extend(true, {}, opts);
			
            handle();
			
        }
    };

}();

